import org.apache.commons.configuration2.INIConfiguration;
import org.apache.commons.configuration2.SubnodeConfiguration;
import org.apache.commons.configuration2.ex.ConfigurationException;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.nio.charset.StandardCharsets;
import java.util.*;

public class IniFileReader {

    public static void main(String[] args) throws ConfigurationException, IOException {
        INIConfiguration iniConfiguration = new INIConfiguration();
        FileReader fr = new FileReader("C:\\Users\\liang-li\\Desktop\\wtx65u-4674.ini");
        System.out.println(fr.getEncoding());
        iniConfiguration.read(fr);
        System.out.println(iniConfiguration.getSection("PROJECT").getProperty("NAME"));
        Map<String, Map<String, String>> ojh = new HashMap<>();
        for (String section : iniConfiguration.getSections()) {
            Map<String, String> subMap = new HashMap<>();
            // 遍历每一个节点
            SubnodeConfiguration confSection = iniConfiguration.getSection(section);
            Iterator<String> keysIterator = confSection.getKeys();
//            System.out.println(keysIterator.next().);
            while (keysIterator.hasNext()) {
                String key = keysIterator.next();
                String value = confSection.getProperty(key).toString();
//                System.out.println(value);
//                System.out.println(key + "=" + value);
                subMap.put(key, value);
            }
            ojh.put(section, subMap);
        }
//        System.out.println(ojh.get("PROJECT"));
    }

}




